/*
 *  Copyright (C) 2025 ameise <ameise.wang@gmail.com> - All Rights Reserved
 *
 *  This file is part of e3net.
 *
 *  e3net is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  e3net is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with e3net. If not, see <https://www.gnu.org/licenses/>.
 */

package e3net

import (
	"gitee.com/ameise84/e3net/internal"
	"gitee.com/ameise84/e3net/internal/packet"
)

func defaultTcpConnOptions() *tcpConnOptions {
	return &tcpConnOptions{
		packetSize:   internal.PacketSize,
		connHoldSize: 4,
		packHandle:   packet.DefaultPackHandler,
	}
}

type tcpConnOptions struct {
	packetSize   uint32             // 消息包最大长度
	connHoldSize uint32             // 连接对象缓冲池回收阈值
	packHandle   packet.PackHandler //打包接口
}

func (ts *tcpConnOptions) SetPacketSize(size uint32) *tcpConnOptions {
	ts.packetSize = size
	return ts
}

func (ts *tcpConnOptions) SetConnHoldSize(size uint32) *tcpConnOptions {
	ts.connHoldSize = size
	return ts
}

func (ts *tcpConnOptions) SetPackHandle(h packet.PackHandler) *tcpConnOptions {
	ts.packHandle = h
	return ts
}
